package com.feshfans;

import com.feshfans.controller.StageManager;
import com.feshfans.xmpp.client.ClientFactory;
import javafx.application.Application;
import javafx.stage.Stage;
import com.feshfans.xmpp.XmppConnectionManager;
import com.feshfans.xmpp.XmppConstants;

public class App extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        primaryStage = StageManager.openOrGetLoginStage();

    }

    /**
     * 初始化 客户端，一定要在一开始初始化完成。
     * 不然，有些消息收不到
     * todo 通过返回加载，否则每添加一个 Client 此外还需要加代码
     */
    private static void initClient(){
        new Thread(new Runnable() {
            @Override
            public void run() {
                ClientFactory.getClient(ClientFactory.ClientType.Message);
                ClientFactory.getClient(ClientFactory.ClientType.Account);
                ClientFactory.getClient(ClientFactory.ClientType.Roster);
            }
        }).start();

    }

    public static void main(String[] args) {
        XmppConnectionManager.create(XmppConstants.serverHost,XmppConstants.port,XmppConstants.domain);
        initClient();
        launch(args);
    }
}
